﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data;

namespace NJL.Web
{
    public partial class SmallFarmHouse : BasePageVisitor
    {
        private readonly BLL.NJL_COMPANY bll = new BLL.NJL_COMPANY();
        private readonly BLL.NJL_SYS_NEWS bllSysNews = new BLL.NJL_SYS_NEWS();
        private readonly BLL.NJL_CS_TAG bllTag = new BLL.NJL_CS_TAG();
        private readonly BLL.NJL_LOCAL_COLOR bllLocalColor = new BLL.NJL_LOCAL_COLOR();
        private readonly BLL.NJL_NEWS bllNews = new BLL.NJL_NEWS();

        protected IList<Model.NJL_COMPANY> LIST_COMPANY;
        protected IList<Model.NJL_SYS_NEWS> LIST_FLASH;
        protected IList<Model.NJL_CS_TAG> LIST_TAG;
        protected IList<Model.NJL_LOCAL_COLOR> LIST_LOCAL_COLOR;
        protected IList<Model.NJL_NEWS> LIST_NEWS;



        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadData();
                base.LoadPageSeoInformation("农家小院");
            }
        }

        private void LoadData()
        {
            if ("" != WEBSITE_FOCUS_CITY_CODE)
            {
                LIST_FLASH = bllSysNews.GetModelList(10, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' AND IS_PUBLISH=1 AND IS_INDEX=1 AND TYPE_CODE='12' ", "SORT DESC,PUBLISH_DATE_TIME DESC");
                LIST_COMPANY = bll.GetModelList(200, " NJL_COMPANY.NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' AND NJL_COMPANY.AUDIT_STATE=1 AND NJL_COMPANY.TYPE_CODE='1' and NJL_COMPANY.AREA_CODE='" + WEBSITE_FOCUS_CITY_CODE + "'", "NJL_COMPANY.SORT DESC,NJL_COMPANY.CREATE_DATE_TIME DESC");

                #region 农家小院
                DataSet ds = bll.GetAllList("NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' AND AUDIT_STATE=1 AND TYPE_CODE='1' and AREA_CODE='" + WEBSITE_FOCUS_CITY_CODE + "'");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    pager.InnerHtml = Royalsoft.Common.Pager.GetPageNum(ds, rptCompany, 16, null, "/"+WEBSITE_FOCUS_CITY_NAME_PINYIN + "/njxy/");
                }
                #endregion
                #region 标签
                LIST_TAG = bllTag.GetModelList(20, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and TAG_TYPE='5' and AREA_CODE='" + WEBSITE_FOCUS_CITY_CODE + "'", "SEARCH_COUNT desc,USED_COUNT DESC");
                #endregion
                #region 美食
                LIST_LOCAL_COLOR = bllLocalColor.GetModelList(4, " NJL_SYS_BASE_ID='" + base.WEBSITE_CODE + "' AND AREA_CODE='" + base.WEBSITE_FOCUS_CITY_CODE + "' AND TYPE_CODE='1' ", "SORT DESC,CREATE_DATE_TIME DESC");
                #endregion
                #region 热点热评
                LIST_NEWS = bllNews.GetModelList(4, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "'", "CREATE_DATE_TIME DESC");
                #endregion
                #region 咨询

                ds = bllSysNews.GetList(8, "NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and  TYPE_CODE='19' and IS_PUBLISH=1 AND IS_INDEX=1 ", "SORT DESC,PUBLISH_DATE_TIME desc");
                rptNews.DataSource = ds;
                rptNews.DataBind();
                #endregion
            }
            else
            {
                LIST_FLASH = bllSysNews.GetModelList(10, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' AND IS_PUBLISH=1 AND IS_INDEX=1 AND TYPE_CODE='12' ", "SORT DESC,PUBLISH_DATE_TIME DESC");
                LIST_COMPANY = bll.GetModelList(200, " NJL_COMPANY.NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' AND NJL_COMPANY.AUDIT_STATE=1 AND NJL_COMPANY.TYPE_CODE='1' ", "NJL_COMPANY.SORT DESC,NJL_COMPANY.CREATE_DATE_TIME DESC");

                #region 农家小院
                DataSet ds = bll.GetAllList("NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' AND AUDIT_STATE=1 AND TYPE_CODE='1' ");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    pager.InnerHtml = Royalsoft.Common.Pager.GetPageNum(ds, rptCompany, 16, null,"/njxy/");
                }
                #endregion
                #region 标签
                LIST_TAG = bllTag.GetModelList(20, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and TAG_TYPE='5' ", "SEARCH_COUNT desc,USED_COUNT DESC");
                #endregion
                #region 美食
                LIST_LOCAL_COLOR = bllLocalColor.GetModelList(4, " NJL_SYS_BASE_ID='" + base.WEBSITE_CODE + "' AND TYPE_CODE='1' ", "SORT DESC,CREATE_DATE_TIME DESC");
                #endregion
                #region 热点热评
                LIST_NEWS = bllNews.GetModelList(4, " NJL_SYS_BASE_ID='" + WEBSITE_CODE + "'", "CREATE_DATE_TIME DESC");
                #endregion
                #region 咨询

                ds = bllSysNews.GetList(8, "NJL_SYS_BASE_ID='" + WEBSITE_CODE + "' and  TYPE_CODE='19' and IS_PUBLISH=1 AND IS_INDEX=1 ", "SORT DESC,PUBLISH_DATE_TIME desc");
                rptNews.DataSource = ds;
                rptNews.DataBind();
                #endregion
            }
        }
    }
}